# -*- coding: utf-8 -*-
"""
# @created on : 9月 2021/9/26 09:09
# @author     : kevin
# @file       : verify.py
# @software   : PyCharm
# @project    : auto_keyword_data


@license: (C) Copyright 2019-2025, Corporation Limited.
@desc:使用ddddocr获取字符类型的验证码，解析并返回验证码内容
"""
import ddddocr


class GetValidCode:

    def get_img_code(self, img):
        """
        解析验证码字符串，并返回解析出的内容
        :param img: 二进制类型的验证码图片内容
        :return: 验证码
        """
        # print(img)
        ocr = ddddocr.DdddOcr()
        # with open(img) as f:
        # img_bytes = img.read()
        res = ocr.classification(img)
        return res